<template>
  <a-card :bordered="false">
    <div>
      <a-form @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="8" :sm="8">
            <a-form-item label="项目名称" :label-col="labelCol" :wrapper-col="wrapperCol">
              <a-input v-model="queryParam.salonName" placeholder="请输入项目名称" />
            </a-form-item>
          </a-col>
          <a-col :md="8" :sm="8">
              <a-form-item label="会议时间" :label-col="labelCol" :wrapper-col="wrapperCol">
                <a-range-picker v-model="queryParam.time" :range-placeholder="['开始时间', '结束时间']"
                 @change='timeChange' format="yyyy/MM/DD" valueFormat="yyyy/MM/DD" style="width: 100%"/>
              </a-form-item>
            </a-col>
          <a-col :md="8" :sm="8">
            <a-form-item>
              <a-button type="primary" icon="search" @click="searchQuery()">查询</a-button>
              <a-button type="primary" icon="reload" style="margin-left: 8px" @click="searchReset()">重置</a-button>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <vxe-grid
        id="ProjectList"
        ref="vxeTable"
        :row-config="{keyField:'id'}"
        v-bind="options"
        v-on="listeners"
    >
      <template #action="{ row }">
        <a @click="handleEdit(row)">编辑</a>
        <a-divider type="vertical" />
        <a @click="SalonApprovalList(row)">审核</a>
        <a-divider type="vertical" />
        <a @click="SignInDetailList(row)">签到详情</a>
        <a-divider type="vertical" />
        <a-dropdown>
            <a class="ant-dropdown-link">二维码 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleApplyQrCode(row)">报名</a>
              </a-menu-item>
              <a-menu-item>
                <a @click="handleSignInQrCode(row)">签到</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
      </template>
    </vxe-grid>
    <a-modal v-model:visible="visible" :destroyOnClose="true" footer="">
      <img
        :width="500"
        :src = "src"
      />
    </a-modal>
    <ProjectModal @ok="modalFormOk" ref="modalForm" />
    <SignInDetail @ok="modalFormOk" ref="SignInInfo" />
    <SalonApproval @ok="modalFormOk" ref="SalonApproval" />
  </a-card>
</template>

<script>
import { VxeTableMixin } from '@/mixins/VxeTableMixin'
import ProjectModal from './modules/ProjectModal'
import SalonApproval from './modules/SalonApproval'
import SignInDetail from './modules/SignInDetail'

export default {
  name: 'ProjectList',
  mixins: [VxeTableMixin],
  components: {
    ProjectModal,
    SalonApproval,
    SignInDetail
  },
  data() {
    return {
      visible:false,
      src:"",
      columns: [
        {type: 'checkbox', width: 40, fixed: 'left'},
        {type: 'seq', width: 40, fixed: 'left'},
        {title: '项目名称', field: 'salonName',width: 200},
        {title: '会议开始时间', field: 'startTime',width: 150},
        {title: '会议结束时间', field: 'endTime',width: 150},
        {title: '主办单位', field: 'organizer',width: 150},
        {title: '会议内容', field: 'describe',width: 200},
        {title: '地址', field: 'address',width: 200},
        {title: '联系人', field: 'contactsPr',width: 100},
        {title: '联系方式', field: 'contactsInfo',width: 120},
        {title: '状态', field: 'statusDesc',width: 100},
        {title: '操作', field: 'operation', width: 300, fixed: 'right', slots: {default: 'action'}}
      ],
      url: {
        list: '/salon/info/v1/page',
        delete: '/salon/info/v1/remove/',
        deleteBatch: '/salon/info/v1/remove/'
      },
      customTableToolbar: {
        import:false
      }
    }
  },
  methods:{
    timeChange(date, dateString) {
      this.form.startTime = dateString[0]
      this.form.endTime = dateString[1]
    },
    //签到二维码
    handleSignInQrCode(row){
      this.visible = true;
      this.src = row.signInQrCode;
    },
    //报名二维码
    handleApplyQrCode(row){
      this.visible = true;
      this.src = row.applyQrCode;
    },
    //签到详情
    SignInDetailList: function(record) {
      debugger
      this.$refs.SignInInfo.getQueryParams(record)
      this.$refs.SignInInfo.loadData(1)
      this.$refs.SignInInfo.visible = true
    },
    //审批
    SalonApprovalList: function(record) {
      this.$refs.SalonApproval.getQueryParams(record)
      this.$refs.SalonApproval.loadData(1)
      this.$refs.SalonApproval.visible = true
    },
  }
}
</script>
